//
//  ViewController.m
//  摇一摇
//
//  Created by mafeng on 16/8/2.
//  Copyright © 2016年 mafeng. All rights reserved.
//

#import "ViewController.h"
#import "myView.h"
@interface ViewController ()
@property (nonatomic, strong) myView *myview;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    _myview = [[myView alloc] initWithFrame:self.view.frame];
    [self.view addSubview:_myview];
    [_myview becomeFirstResponder];
}

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
    _myview.backgroundColor = [UIColor greenColor];
    // 摇晃开始
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
    _myview.backgroundColor = [UIColor yellowColor];
    // 摇晃结束
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event {
    _myview.backgroundColor = [UIColor purpleColor];
    // 摇晃终止
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
